﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	GoodsDetail
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<style type="text/css">
  .goods_main{ width:730px; float:right;  padding:0 2px;}
</style>

    <link href="/content/css/layout.css" type="text/css" rel="stylesheet" />
    <link href="/content/art_dialog/skins/idialog.css" rel="stylesheet" />
    <script src="/scripts/jquery-1.6.2.min.js" type="text/javascript"></script>
    <script src="/scripts/showpro/cloud-zoom.1.0.2.js" type="text/javascript"></script>

     <script type="text/javascript">
         $( function () {
             $( "#btnGoodsComment" ).click( function () {
                 if ( $( "#txtaContent" ).val() == "" ) {
                     $( "#txtaContent" ).select();
                     $( "#spContent" ).html( "<img src=\"/script/images/wrong.gif\" />请输入评论内容！" );
                     return false;
                 } else {
                     if ( $( "#txtaContent" ).val().length > 500 ) {
                         $( "#txtaContent" ).select();
                         $( "#spContent" ).html( "<img src=\"/script/images/wrong.gif\" />评论内容不能超过500个字符！" );
                         return false;
                     } else $( "#spContent" ).html( "<img src=\"/script/images/right.gif\" />" );
                 }
                 if ( $( "#txtCommentCode" ).val() == "" ) {
                     $( "#txtCommentCode" ).select();
                     $( "#spCommentCode" ).html( "<img src=\"/script/images/wrong.gif\" />请输入验证码！" );
                     return false;
                 } else $( "#spCommentCode" ).html( "<img src=\"/script/images/right.gif\" />" );
                 $.ajax( {
                     type: "POST",
                     url: "goodsCommentHandler.ashx",
                     data: "id=" + $( "#hdGoods" ).val() + "&contact=" + escape( $( "#txtContact" ).val() ) + "&content=" + escape( $( "#txtaContent" ).val() ) + "&code=" + $( "#txtCommentCode" ).val(),
                     success: function ( msg ) {
                         if ( msg == "0" ) {
                             TB_show( null, "login.html?TB_iframe=true&height=370&width=640", false );
                         } else if ( msg == "1" ) {
                             $( "#txtCommentCode" ).select();
                             $( "#spCommentCode" ).html( "<img src=\"/script/images/wrong.gif\" />验证码错误，请重新输入！" );
                             $( "#imgCheckCommentCode" ).attr( "src", "/code.aspx?a=" + Math.random() + "&t=conmment" );
                         } else if ( msg == "2" ) {
                             art.dialog.tips( "很抱歉，评论失败！", 1.5 );
                         }
                         else {
                             art.dialog.tips( "恭喜您，评论成功！", 1.5 );
                             $( "#goods_comment" ).html( msg );
                             $( '#formComment' )[0].reset(); //表单重置
                             $( "#spContent" ).html( "*最多可输入200个字符" );
                             $( "#spCommentCode" ).html( "" );
                             $( "#imgCheckCommentCode" ).attr( "src", "/code.aspx?a=" + Math.random() + "&t=conmment" );
                         }
                     }
                 } );
                 return false;
             } );
             $( "#btnScoreSubmit" ).click( function () {
                 if ( $( "input[name='commodityScore']:checked" ).val() == null ) {
                     art.dialog.tips( "请选择星级！", 1.5 );
                     //                    $("#spCommodityScore").html("<img src=\"/script/images/wrong.gif\" />请选择星级！");
                     return false;
                 } else {
                     $.ajax( {
                         type: "POST",
                         url: "commodityScoreHandler.ashx",
                         data: "id=" + $( "#hdGoods" ).val() + "&score=" + $( "input[name='commodityScore']:checked" ).val(),
                         success: function ( msg ) {
                             //                            $("#spCommodityScore").html("");
                             if ( msg == "0" ) {
                                 TB_show( null, "login.html?TB_iframe=true&height=370&width=640", false );
                             }
                             else if ( msg == "1" ) {
                                 art.dialog.tips( "很抱歉，评分失败！", 1.5 );
                             } else {
                                 art.dialog.tips( "恭喜您，评分成功！", 1.5 );
                                 $( '#formScore' )[0].reset(); //表单重置
                                 $( "#pScore" ).html( msg.split( "+" )[0] );
                                 $( "#divScore" ).html( msg.split( "+" )[1] );
                             }
                         }
                     } );
                     return false;
                 }
             } );
             $( "#btnCountJian" ).click( function () {
                 if ( parseInt( $( "#txtCount" ).val() ) > 0 )
                     $( "#txtCount" ).val( parseInt( $( "#txtCount" ).val() ) - 1 );
             } );
             $( "#btnCountJia" ).click( function () {
                 if ( parseInt( $( "#spInventory" ).text() ) > parseInt( $( "#txtCount" ).val() ) )
                     $( "#txtCount" ).val( parseInt( $( "#txtCount" ).val() ) + 1 );
             } );
         

         } );



         function aAddShoppingCart(){

             if ( $( "#txtCount" ).val() == "0" ) {
                 art.dialog.tips( "请输入购买数量！", 1.5 );
                 return false;
             }
             else {
                 $.ajax( {
                     type: "POST",
                     url: "/service/addShoppingCartHandler.ashx",
                     data: "goodsEntitys=" + $( "#hdGoodsEntitys" ).val() + "&count=" + $( "#txtCount" ).val(),
                     success: function ( msg ) {
                         if ( msg == "0" ) customButton( '添加至购物车成功！', '立即结算', '/home/shoppingcart', '继续购物' );
                         else if ( msg == "1" ) art.dialog.tips( "添加购物车失败，商品库存不足！", 1.5 );

                     }
                 } );
             }
             return false;
         }


         ///商品收藏
         function aFavorites() {
          
             $.ajax( {
                 type: "POST",
                 url: "/service/goodsFavoritesHandler.ashx",
                 data: "id=" + $( "#hdGoods" ).val(),
                 success: function ( msg ) {
                     if ( msg == "0" ) TB_show( null, "/Home/Login?TB_iframe=true&height=370&width=640", false );
                     else if ( msg == "1" ) art.dialog.tips( "此商品已收藏，请不要重复添加！", 1.5 );
                     else if ( msg == "2" ) art.dialog.tips( "恭喜您，收藏成功！", 1.5 );
                     else if ( msg == "3" ) art.dialog.tips( "很抱歉，收藏失败！", 1.5 );
                 }
             } );
             return false;
         }



         function send_request( url, poststr ) {
             http_request = false;
             if ( window.XMLHttpRequest ) {
                 http_request = new XMLHttpRequest();
                 if ( http_request.overrideMimeType ) {
                     http_request.overrideMimeType( 'text/xml' );
                 }
             } else if ( window.ActiveXObject ) {
                 try {
                     http_request = new ActiveXObject( "Msxml2.XMLHTTP" );
                 } catch ( e ) {
                     try {
                         http_request = new ActiveXObject( "Microsoft.XMLHTTP" );
                     } catch ( e ) { }
                 }
             }
             if ( !http_request ) return false;
             http_request.onreadystatechange = processRequest;
             http_request.open( "POST", url, true );
             http_request.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
             http_request.send( poststr );
         }
         function processRequest() {
             if ( http_request.readyState == 4 ) {
                 if ( http_request.status == 200 ) {
                     if ( http_request.responseText != "" ) {
                         var returnValue = http_request.responseText.split( "+" );
                         $( "#goodsArtno" ).text( returnValue[0] );
                         $( "#pPrice" ).html( returnValue[1] );
                         $( "#spInventory" ).html( returnValue[2] );
                         if ( parseInt( returnValue[2] ) > 0 ) $( "#txtCount" ).val( "1" );
                         else $( "#txtCount" ).val( "0" );
                         $( "#hdSpecificationsValueList" ).val( returnValue[3] );
                         $( "#liChooseSpecifications" ).html( returnValue[4] );
                         $( "#liSpecifications" ).html( returnValue[5] );
                         $( "#hdGoodsEntitys" ).val( returnValue[6] );
                     }
                 } else { }
             }
         }
         function chooseSpecifications( ge, s, sv ) {
             poststr = "goodsEntitys=" + ge + "&specifications=" + s + "&specificationsValue=" + sv + "&goods=" + $( "#hdGoods" ).val() + "&SpecificationsList=" + $( "#hdSpecificationsList" ).val() + "&SpecificationsValueList=" + $( "#hdSpecificationsValueList" ).val();
             send_request( 'specificationsHandler.ashx', poststr );
             return false;
         }
         function send_request1( url, poststr ) {
             http_request = false;
             if ( window.XMLHttpRequest ) {
                 http_request = new XMLHttpRequest();
                 if ( http_request.overrideMimeType ) {
                     http_request.overrideMimeType( 'text/xml' );
                 }
             } else if ( window.ActiveXObject ) {
                 try {
                     http_request = new ActiveXObject( "Msxml2.XMLHTTP" );
                 } catch ( e ) {
                     try {
                         http_request = new ActiveXObject( "Microsoft.XMLHTTP" );
                     } catch ( e ) { }
                 }
             }
             if ( !http_request ) return false;
             http_request.onreadystatechange = processRequest1;
             http_request.open( "POST", url, true );
             http_request.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
             http_request.send( poststr );
         }
         function processRequest1() {
             if ( http_request.readyState == 4 ) {
                 if ( http_request.status == 200 ) {
                     if ( http_request.responseText != "" ) {
                         $( "#pFreight" ).html( http_request.responseText );
                     }
                 } else { }
             }
         }
         function changeFreight( fid, rn, name ) {
             poststr = "fid=" + fid + "&rn=" + escape( rn );
             send_request1( 'freightWayHandler.ashx', poststr );
             $( "#region" ).html( name );
             $( "a[s]" ).removeClass( 'sbg' );
             $( ".city" ).hide();
             $( "#storeinfo" ).removeClass( 'hover' );
             return false;
         }




    function setGoodsDetailBody() {

        $.post( "/Service/GoodsDetailHandler.ashx?type=CategoryTopSelling&id=" + '<%=   ViewData["goodsId"] %>', function ( data ) {
            $( '#CategoryTopSellingBind' ).html( data );

        } );
        $.post( "/Service/GoodsDetailHandler.ashx?type=UserBrowse&id=" + '<%=   ViewData["goodsId"] %>', function ( data ) {
            $( '#UserBrowseBind' ).html( data );

        } );
        $.post( "/Service/GoodsDetailHandler.ashx?type=RecentBrowseBoods&id=" + '<%=   ViewData["goodsId"] %>', function ( data ) {
            $( '#RecentBrowseBoodsBind' ).html( data );

        } );
        $.post( "/Service/GoodsDetailHandler.ashx?type=GoodGallery&id=" + '<%=   ViewData["goodsId"] %>', function ( data ) {
            $( '#GoodGalleryBind' ).html( data );

        } );
        $.post( "/Service/GoodsDetailHandler.ashx?type=SetSpecificationsValueList&id=" + '<%=   ViewData["goodsId"] %>', function ( data ) {
            $( '#SetSpecificationsValueList' ).html( data );

        } );
        $.post( "/Service/GoodsDetailHandler.ashx?type=GoodsEntitys&id=" + '<%=   ViewData["goodsId"] %>', function ( data ) {
            $( '#GoodsEntitysBind' ).html( data );

        } );
        $.post( "/Service/GoodsDetailHandler.ashx?type=GoodsDetailed&id=" + '<%=   ViewData["goodsId"] %>', function ( data ) {
            $( '#GoodsDetailedBind' ).html( data );

        } );

    }

    $( document ).ready( function () {
        setGoodsDetailBody();
    } )


    </script>


    <center>
       <div class="contain">

      <div class="sidebar" >
      <div id="CategoryTopSellingBind"></div>
      <div id="UserBrowseBind"></div>
      <div id="RecentBrowseBoodsBind"></div>

        </div>

             <div id="GoodGalleryBind"></div>
        <!--产品动画结束-->
        <div id="SetSpecificationsValueList"></div>
        <div id="GoodsEntitysBind"></div>

          <!--end sidebar-->
            <div id="GoodsDetailedBind"></div>

        <span class="clear"></span>
    </div>
    </center>
    <div class="clear"></div>


</asp:Content>
